package base.study.chapter7;

import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * TODO(用一句话描述方法的主要功能)
 */
public class Demo1 {

    private static final Logger logger = Logger.getLogger("base.study.chapter7.Demo1");

    static {
        //设置日期处理器
        logger.setLevel(Level.FINER);
        //logger.setUseParentHandlers(false);
        ConsoleHandler consoleHandler = new ConsoleHandler();
        consoleHandler.setLevel(Level.FINER);

        try {
            FileHandler fileHandler = new FileHandler();
            logger.addHandler(fileHandler);
        } catch (IOException e) {
            e.printStackTrace();
        }
        //logger.addHandler(consoleHandler);
    }

    public void testLog() {
        IOException exception = new IOException("测试");
        logger.throwing("base.study.chapter7.Demo1","testLog",exception);
        logger.finer("test_finer");
        logger.fine("testLog_fine");
        logger.info("testLog");
        logger.warning("testLog_warning");
    }

    public static void main(String[] args) {
        Demo1 demo1 = new Demo1();
        demo1.testLog();
    }
}
